Function to write in top, write on bottom, overwrite o delete file.

Use:
file_save ($text, $file, $mode);

$text = the text for write
$file = the file to write
$mode = way to write

Ways to write:
-bottom to write on the bottom
-top to write on the top
-overwrite to overwrite the file

=======================================================

<?php
//Save file:
//	-bottom       to write on the bottom
//	-top          to write on the top
//	-overwrite    to overwrite the file

function file_save ($text, $file, $mode) {
	if ($mode == "top") {
		$file_text=file_get_contents($file);
		$fp=fopen($file, "w+");
		fwrite($fp, "${text}${file_text}");
		fclose($fp);
		}
	else if ($mode == "bottom") {
		$fp=fopen($file, "a+");
		fwrite($fp, "${text}");
		fclose($fp);		
		}
	else if ($mode == "overwrite") {
		$fp=fopen($file, "w+");
		fwrite($fp, "${text}");
		fclose($fp);
		}
	else {
		return 0;
		}
}
?>